<?php
global $language, $user;
$body = field_get_items('node', $node, 'body', $language->language);
$body = !empty($body) ? $body[0]['value'] : '';
$field_job_code = field_get_items('node', $node, 'field_job_code', $language->language);
$field_job_code = !empty($field_job_code) ? $field_job_code[0]['value'] : '';
$field_location = get_taxonomy_term_of_field('field_location', $node);
$field_location = !empty($field_location) ? $field_location->name : '';
$field_salary = field_get_items('node', $node, 'field_salary', $language->language);
$field_salary = !empty($field_salary) ? $field_salary[0]['value'] : '';
$field_industry = get_taxonomy_term_of_field('field_industry', $node);
$field_industry = !empty($field_industry) ? $field_industry->name : '';
$field_job_description = field_get_items('node', $node, 'field_job_description', $language->language);
$field_job_description = !empty($field_job_description) ? $field_job_description[0]['value'] : '';
$field_requirements = field_get_items('node', $node, 'field_requirements', $language->language);
$field_requirements = !empty($field_requirements) ? $field_requirements[0]['value'] : '';
?>
<h2><?php print $node->title; ?></h2>
<div class="block-decription">
  <h3 class="title-2"><?php print t('Employer Description'); ?></h3>
  <div class="inner">
    <?php print $body; ?>
  </div>
</div>
<div class="block-detail">
  <h3 class="title-2"><?php print t('Job Details'); ?></h3>
  <div class="inner">
    <ul class="lst-detail">
      <li>
        <span><?php print t('Job Name'); ?>:</span> 
        <div class="fck">
          <span><?php print $node->title; ?></span> 
        </div>    
      </li>
      <li>
        <span><?php print t('Job Code'); ?>:</span>
        <div class="fck">
          <span><?php print $field_job_code; ?></span> 
        </div>  
      </li>
      <li>
        <span><?php print t('Location'); ?>:</span>
        <div class="fck">
          <span><?php print $field_location; ?></span> 
        </div>  
      </li>
      <li>
        <span><?php print t('Salary'); ?>:</span>
        <div class="fck">
          <span><?php print $field_salary . (is_numeric($field_salary) ? '$' : ''); ?></span> 
        </div>  
      </li>
      <li>
        <span><?php print t('Industry'); ?>:</span>
        <div class="fck">
          <span><?php print $field_industry; ?></span> 
        </div>  
      </li>
      <li>
        <span><?php print t('Job Description'); ?>:</span>
        <div class="fck">
          <?php print $field_job_description; ?>
        </div>
      </li>
      <li>
        <span><?php print t('Requirements'); ?>:</span>
        <div class="fck">
          <?php print $field_requirements; ?>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="job_apply">
  <h3 class="title-2"><?php print t('Application Form'); ?></h3>
  <div class="job_content">
    <?php
    if (!user_is_logged_in()) {
      ?>
      <a href="javascript:void()" class="lightbox-processed" name="modal"><?php print t('Login'); ?></a> <?php print t('or'); ?> <a href="<?php print url('user/register'); ?>"><?php print t('Register and Submit CV'); ?></a>					
      <?php
    } else {
      $application = get_application($node->nid, $user->uid);
      if (empty($application)) {
        ?>
        <a href="<?php print url('apply-cv/' . base64_url_encode($node->nid)); ?>"><?php print t('Apply CV'); ?></a>
        <?php
      } else {
        print t('Your CV has been applied. Thank you');
      }
    }
    ?>
  </div>
</div>